/*
 * God.java
 *
 * Created on January 6, 2008, 3:16 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package wisp.dataObjects;
import java.sql.*;
import java.io.*;
import java.util.*;
import java.util.Vector;
import java.lang.Exception.*;
/**
 *
 * @author Nezie Santos
 */
public class God {
    private dbConnection dbcon = new dbConnection();
    private String godName, lineage, beast, bless, beastDes, blessDes, at1, at2, mpic,gpic, bpic;
    private int favorLR, favorHR, damageLR, damageHR, maxExp, maxMoney, maxHP, deedPt, turn, battle;
    private double val1, val2;
    /** Creates a new instance of God */
    public God( String godNames,String lineages,String beasts,String blesss,String beastDess,String blessDess, String a1, String a2, double v1, double v2, int dpt, int b, int t, int favorLRs,int favorHRs,int damageLRs,int damageHRs,int maxExps,int maxMoneys,int maxHPs) {
    this.setBeast(beasts);
    this.setBeastDes(beastDess);
    this.setBless(blesss);
    this.setBlessDes(blessDess);
    this.setDamageHR(damageHRs);
    this.setDamageLR(damageLRs);
    this.setFavorHR(favorHRs);
    this.setFavorLR(favorLRs);
    this.setGodName(godNames);
    this.setLineage(lineages);
    this.setMaxExp(maxExps);
    this.setMaxHP(maxHPs);
    this.setMaxMoney(maxMoneys);
    setAt1(a1);
    setAt2(a2);
    setVal1(v1);
    setVal2(v2);
    setDeedPt(dpt);
    turn = t;
    battle = b;
    }
   public God() {
    }
   
   public void viewBlessInfo (String bName){
        String query;
        ResultSet rs;
        PreparedStatement stmt;
                
        getDbcon().connect();
        query = "SELECT turn, battle, deedPt, val1, val2, at1, at2, godName, lineage, beast, bless, beastDes, blessDes, favorLR, favorHR, damageLR, damageHR, maxExp, maxMoney, maxHP, mpic, bpic, gpic FROM God WHERE bless = ?";
        
        try
        {
            stmt = getDbcon().con.prepareStatement(query);
            stmt.setString(1, bName);
            rs = stmt.executeQuery();	
        
            while (rs.next()) 
            {
            	turn = rs.getInt("turn");
            	battle = rs.getInt("battle");
                setDeedPt(rs.getInt("deedPt"));
                setVal1(rs.getDouble("val1"));
                setVal2(rs.getDouble("val2"));
                setAt1(rs.getString("at1"));
                setAt2(rs.getString("at2"));
                this.setGodName(rs.getString("godName"));
                this.setLineage(rs.getString("lineage"));
                this.setBeast(rs.getString("beast"));
                this.setBless(rs.getString("bless"));
                this.setBeastDes(rs.getString("beastDes"));
                this.setBlessDes(rs.getString("blessDes"));
                this.setFavorLR(rs.getInt("favorLR"));
                this.setFavorHR(rs.getInt("favorHR"));
                this.setDamageLR(rs.getInt("damageLR"));
                this.setDamageHR(rs.getInt("damageHR"));
                this.setMaxExp(rs.getInt("maxExp"));
                this.setMaxMoney(rs.getInt("maxMoney"));
                this.setMaxHP(rs.getInt("maxHP"));
                this.setMpic(rs.getString("mpic").trim());
                this.setBpic(rs.getString("bpic").trim());
                this.setGpic(rs.getString("gpic").trim());
                
            }
            rs.close(); 					
            stmt.close();
        } catch (Exception ex)
        {
            System.out.println(ex.getMessage());	       	
        }
        finally {
            getDbcon().disconnect();
 
        }
    }
    public void viewCurseInfo (String bName){
        String query;
        ResultSet rs;
        PreparedStatement stmt;
                
        getDbcon().connect();
        query = "SELECT turn, battle, deedPt, val1, val2, at1, at2, godName, lineage, beast, bless, beastDes, blessDes, favorLR, favorHR, damageLR, damageHR, maxExp, maxMoney, maxHP, mpic, bpic, gpic FROM God WHERE beast = ?";
        
        try
        {
            stmt = getDbcon().con.prepareStatement(query);
            stmt.setString(1, bName);
            rs = stmt.executeQuery();	
        
            while (rs.next()) 
            {
            	turn = rs.getInt("turn");
            	battle = rs.getInt("battle");
                setDeedPt(rs.getInt("deedPt"));
                setVal1(rs.getDouble("val1"));
                setVal2(rs.getDouble("val2"));
                setAt1(rs.getString("at1"));
                setAt2(rs.getString("at2"));
                this.setGodName(rs.getString("godName"));
                this.setLineage(rs.getString("lineage"));
                this.setBeast(rs.getString("beast"));
                this.setBless(rs.getString("bless"));
                this.setBeastDes(rs.getString("beastDes"));
                this.setBlessDes(rs.getString("blessDes"));
                this.setFavorLR(rs.getInt("favorLR"));
                this.setFavorHR(rs.getInt("favorHR"));
                this.setDamageLR(rs.getInt("damageLR"));
                this.setDamageHR(rs.getInt("damageHR"));
                this.setMaxExp(rs.getInt("maxExp"));
                this.setMaxMoney(rs.getInt("maxMoney"));
                this.setMaxHP(rs.getInt("maxHP"));
                this.setMpic(rs.getString("mpic").trim());
                this.setBpic(rs.getString("bpic").trim());
                this.setGpic(rs.getString("gpic").trim());
            }
            rs.close(); 					
            stmt.close();
        } catch (Exception ex)
        {
            System.out.println(ex.getMessage());	       	
        }
        finally {
            getDbcon().disconnect();
 
        }
    }
    public void viewInfoByMonsId (int monsId){
        String query;
        ResultSet rs;
        PreparedStatement stmt;
                
        getDbcon().connect();
        query = "SELECT turn, battle, deedPt, val1, val2, at1, at2, godName, lineage, beast, bless, beastDes, blessDes, favorLR, favorHR, damageLR, damageHR, maxExp, maxMoney, maxHP, mpic, bpic, gpic FROM God WHERE monsId = ?";
        
        try
        {
            stmt = getDbcon().con.prepareStatement(query);
            stmt.setInt(1, monsId);
            rs = stmt.executeQuery();	
        
            while (rs.next()) 
            {
            	turn = rs.getInt("turn");
            	battle = rs.getInt("battle");
                setDeedPt(rs.getInt("deedPt"));
                setVal1(rs.getDouble("val1"));
                setVal2(rs.getDouble("val2"));
                setAt1(rs.getString("at1"));
                setAt2(rs.getString("at2"));
                this.setGodName(rs.getString("godName"));
                this.setLineage(rs.getString("lineage"));
                this.setBeast(rs.getString("beast"));
                this.setBless(rs.getString("bless"));
                this.setBeastDes(rs.getString("beastDes"));
                this.setBlessDes(rs.getString("blessDes"));
                this.setFavorLR(rs.getInt("favorLR"));
                this.setFavorHR(rs.getInt("favorHR"));
                this.setDamageLR(rs.getInt("damageLR"));
                this.setDamageHR(rs.getInt("damageHR"));
                this.setMaxExp(rs.getInt("maxExp"));
                this.setMaxMoney(rs.getInt("maxMoney"));
                this.setMaxHP(rs.getInt("maxHP"));
                this.setMpic(rs.getString("mpic").trim());
                this.setBpic(rs.getString("bpic").trim());
                this.setGpic(rs.getString("gpic").trim());
            }
            rs.close(); 					
            stmt.close();
        } catch (Exception ex)
        {
            System.out.println(ex.getMessage());	       	
        }
        finally {
            getDbcon().disconnect();
 
        }
    }
    public Vector viewByLineageWithFavor (String lName, double fPt, String type ){
        //Statement stmt;
        String query;
        ResultSet rs;
        PreparedStatement stmt;
        Vector<God> gList;
            
        gList = new Vector<God>();
        Iterator it =gList.iterator();
                
        getDbcon().connect();
        if (type.equals("bless"))
        {
            if (fPt > 0)
                query = "SELECT turn, battle, deedPt, val1, val2, at1, at2, godName, lineage, beast, bless, beastDes, blessDes, favorLR, favorHR, damageLR, damageHR, maxExp, maxMoney, maxHP, mpic, bpic, gpic FROM God WHERE lineage = ? AND favorPt <= ? AND favorPt > 0 AND beast = ?";
 
            else
               query = "SELECT turn, battle, deedPt, val1, val2, at1, at2, godName, lineage, beast, bless, beastDes, blessDes, favorLR, favorHR, damageLR, damageHR, maxExp, maxMoney, maxHP,  mpic, bpic, gpic FROM God WHERE lineage = ? AND favorPt >= ? AND favorPt < 0 AND beast = ?";
        }
        else
        {
            if (fPt > 0)
                query = "SELECT turn, battle, deedPt, val1, val2, at1, at2, godName, lineage, beast, bless, beastDes, blessDes, favorLR, favorHR, damageLR, damageHR, maxExp, maxMoney, maxHP,  mpic, bpic, gpic FROM God WHERE lineage = ? AND favorPt <= ? AND favorPt > 0 AND bless = ?";
 
            else
               query = "SELECT turn, battle, deedPt, val1, val2, at1, at2, godName, lineage, beast, bless, beastDes, blessDes, favorLR, favorHR, damageLR, damageHR, maxExp, maxMoney, maxHP,  mpic, bpic, gpic FROM God WHERE lineage = ? AND favorPt >= ? AND favorPt < 0 AND bless = ?";
        }
        try
        {
            stmt = getDbcon().con.prepareStatement(query);
            stmt.setString(1, lName);
            stmt.setDouble(2, fPt);
            stmt.setString(3, "none");
            //stmt.setString(4, "none");
            rs = stmt.executeQuery();
        
            while (rs.next()) 
            {	
                God g = new God();
                g.turn = rs.getInt("turn");
            	g.battle = rs.getInt("battle");
                g.setDeedPt(rs.getInt("deedPt"));
                g.setVal1(rs.getDouble("val1"));
                g.setVal2(rs.getDouble("val2"));
                g.setAt1(rs.getString("at1"));
                g.setAt2(rs.getString("at2"));
                g.setGodName(rs.getString("godName"));
                g.setLineage(rs.getString("lineage"));
                g.setBeast(rs.getString("beast"));
                g.setBless(rs.getString("bless"));
                g.setBeastDes(rs.getString("beastDes"));
                g.setBlessDes(rs.getString("blessDes"));
                g.setFavorLR(rs.getInt("favorLR"));
                g.setFavorHR(rs.getInt("favorHR"));
                g.setDamageLR(rs.getInt("damageLR"));
                g.setDamageHR(rs.getInt("damageHR"));
                g.setMaxExp(rs.getInt("maxExp"));
                g.setMaxMoney(rs.getInt("maxMoney"));
                g.setMaxHP(rs.getInt("maxHP"));
                  g.setMpic(rs.getString("mpic"));
                g.setBpic(rs.getString("bpic"));
                g.setGpic(rs.getString("gpic"));
                gList.add(g);
               
             }
            //crset.populate(rs);
            rs.close(); 					
            stmt.close();
            return gList;
 				
        } catch (Exception ex)
        {
            System.out.println(ex.getMessage());	       	
        }
       finally {
            getDbcon().disconnect();
        }
        return null;
     }
    
    public Vector viewCharBless (String cname ){
        //Statement stmt;
        String query;
        ResultSet rs;
        PreparedStatement stmt;
        Vector<God> gList;
            
        gList = new Vector<God>();
        Iterator it =gList.iterator();
                
        getDbcon().connect();
         query = "SELECT God.turn, God.battle, God.deedPt, God.val1, God.val2, God.at1, God.at2, God.godName, God.lineage, God.beast, God.bless, God.beastDes, God.blessDes, God.favorLR, God.favorHR, God.damageLR, God.damageHR, God.maxExp, God.maxMoney, God.maxHP,  God.mpic, God.bpic, God.gpic FROM God, Blurse WHERE God.bless = Blurse.godname AND Blurse.characterName = ?";
                                                                                                                                                                                                                                                                                              
        try
        {
            stmt = getDbcon().con.prepareStatement(query);
            stmt.setString(1, cname);
            rs = stmt.executeQuery();
        
            while (rs.next()) 
            {	
                God g = new God();
                g.turn = rs.getInt("turn");
            	g.battle = rs.getInt("battle");
                g.setDeedPt(rs.getInt("deedPt"));
                g.setVal1(rs.getDouble("val1"));
                g.setVal2(rs.getDouble("val2"));
                g.setAt1(rs.getString("at1"));
                g.setAt2(rs.getString("at2"));
                g.setGodName(rs.getString("godName"));
                g.setLineage(rs.getString("lineage"));
                g.setBeast(rs.getString("beast"));
                g.setBless(rs.getString("bless"));
                g.setBeastDes(rs.getString("beastDes"));
                g.setBlessDes(rs.getString("blessDes"));
                g.setFavorLR(rs.getInt("favorLR"));
                g.setFavorHR(rs.getInt("favorHR"));
                g.setDamageLR(rs.getInt("damageLR"));
                g.setDamageHR(rs.getInt("damageHR"));
                g.setMaxExp(rs.getInt("maxExp"));
                g.setMaxMoney(rs.getInt("maxMoney"));
                g.setMaxHP(rs.getInt("maxHP"));
                g.setMpic(rs.getString("mpic"));
                g.setBpic(rs.getString("bpic"));
                g.setGpic(rs.getString("gpic"));
           
                gList.add(g);
               
             }
            //crset.populate(rs);
            rs.close(); 					
            stmt.close();
            return gList;
 				
        } catch (Exception ex)
        {
            System.out.println(ex.getMessage());	       	
        }
       finally {
            getDbcon().disconnect();
        }
        return null;
     }

    public dbConnection getDbcon() {
        return dbcon;
    }

    public void setDbcon(dbConnection dbcon) {
        this.dbcon = dbcon;
    }

    public String getGodName() {
        return godName;
    }

    public void setGodName(String godName) {
        this.godName = godName;
    }

    public String getLineage() {
        return lineage;
    }

    public void setLineage(String lineage) {
        this.lineage = lineage;
    }

    public String getBeast() {
        return beast;
    }

    public void setBeast(String beast) {
        this.beast = beast;
    }

    public String getBless() {
        return bless;
    }

    public void setBless(String bless) {
        this.bless = bless;
    }

    public String getBeastDes() {
        return beastDes;
    }

    public void setBeastDes(String beastDes) {
        this.beastDes = beastDes;
    }

    public String getBlessDes() {
        return blessDes;
    }

    public void setBlessDes(String blessDes) {
        this.blessDes = blessDes;
    }

    public int getFavorLR() {
        return favorLR;
    }

    public void setFavorLR(int favorLR) {
        this.favorLR = favorLR;
    }

    public int getFavorHR() {
        return favorHR;
    }

    public void setFavorHR(int favorHR) {
        this.favorHR = favorHR;
    }

    public int getDamageLR() {
        return damageLR;
    }

    public void setDamageLR(int damageLR) {
        this.damageLR = damageLR;
    }

    public int getDamageHR() {
        return damageHR;
    }

    public void setDamageHR(int damageHR) {
        this.damageHR = damageHR;
    }

    public int getMaxExp() {
        return maxExp;
    }

    public void setMaxExp(int maxExp) {
        this.maxExp = maxExp;
    }

    public int getMaxMoney() {
        return maxMoney;
    }

    public void setMaxMoney(int maxMoney) {
        this.maxMoney = maxMoney;
    }

    public int getMaxHP() {
        return maxHP;
    }

    public void setMaxHP(int maxHP) {
        this.maxHP = maxHP;
    }

    public String getAt1() {
        return at1;
    }

    public void setAt1(String at1) {
        this.at1 = at1;
    }

    public String getAt2() {
        return at2;
    }

    public void setAt2(String at2) {
        this.at2 = at2;
    }

    public int getDeedPt() {
        return deedPt;
    }

    public void setDeedPt(int deedPt) {
        this.deedPt = deedPt;
    }

    public double getVal1() {
        return val1;
    }

    public void setVal1(double val1) {
        this.val1 = val1;
    }

    public double getVal2() {
        return val2;
    }

    public void setVal2(double val2) {
        this.val2 = val2;
    }
    public int getTurn() {
        return turn;
    }

    public void setTurn(int turn) {
        this.turn = turn;
    }
      public int getBattle() {
        return battle;
    }

    public void setBattle(int battle) {
        this.battle = battle;
    }

    public String getMpic() {
        return mpic;
    }

    public void setMpic(String mpic) {
        this.mpic = mpic;
    }

    public String getGpic() {
        return gpic;
    }

    public void setGpic(String gpic) {
        this.gpic = gpic;
    }

    public String getBpic() {
        return bpic;
    }

    public void setBpic(String bpic) {
        this.bpic = bpic;
    }
}
